;Assembler header file for Buffer
;written by DefMod (Dec 31 2005) on Sat Dec 31 14:03:52 2005
;Jonathan Coxhead, jonathan@doves.demon.co.uk, 21 Aug 1995

        [       :LNOT: :DEF: Buffer_Hdr
        GBLS    Buffer_Hdr

        [       :LNOT: :DEF: Get_Types
        GBLS    Get_Types
        ]
        [       :LNOT: :DEF: Types_Hdr
Get_Types                       SETS    "GET oslib/Types.Hdr"
        |
Get_Types                       SETS    ""
        ]
        $Get_Types

        [       :LNOT: :DEF: Get_OS
        GBLS    Get_OS
        ]
        [       :LNOT: :DEF: OS_Hdr
Get_OS                          SETS    "GET oslib/OS.Hdr"
        |
Get_OS                          SETS    ""
        ]
        $Get_OS

;Symbols for constants
Buffer_Keyboard                 *       &0
Buffer_RS423Input               *       &1
Buffer_RS423Output              *       &2
Buffer_Printer                  *       &3
Buffer_SoundChannel0            *       &4
Buffer_SoundChannel1            *       &5
Buffer_SoundChannel2            *       &6
Buffer_SoundChannel3            *       &7
Buffer_Speech                   *       &8
Buffer_Mouse                    *       &9
Buffer_Dormant                  *       &1
Buffer_EventOnEmpty             *       &2
Buffer_EventOnFull              *       &4
Buffer_UpCallOnThreshold        *       &8
Error_BufferManagerBadSWI       *       &20700
Error_BufferManagerTooManyBuffers *       &20700
Error_BufferManagerBadBuffer    *       &20700
Error_BufferManagerInUse        *       &20700
Error_BufferManagerUnableToDetach *       &20700
Error_BufferManagerHandleAlreadyUsed *       &20700
Error_BufferManagerBufferTooSmall *       &20700
Error_BufferManagerBadParm      *       &20700
Buffer_ServiceInsertByte        *       &0
Buffer_ServiceInsertBlock       *       &1
Buffer_ServiceRemoveByte        *       &2
Buffer_ServiceRemoveBlock       *       &3
Buffer_ServiceExamineByte       *       &4
Buffer_ServiceExamineBlock      *       &5
Buffer_ServiceUsedSpace         *       &6
Buffer_ServiceFreeSpace         *       &7
Buffer_ServicePurgeBuffer       *       &8
Buffer_ServiceNextFilledBlock   *       &9
CnpV_CountEntries               *       &0
CnpV_NumberFree                 *       &20000000
CnpV_Purge                      *       &10000000

;Symbols for structure offsets and sizes
                                ^       0
                                #       Int
Buffer_No                       *       @

                                ^       0
                                #       Bits
Buffer_Flags                    *       @

Buffer_B                        *       4 ;abstract type
Buffer_InternalId               *       4 ;abstract type
                                ^       0
                                #       Int
Buffer_ServiceOp                *       @

                                ^       0
Buffer_MouseData_x              #       Short
Buffer_MouseData_y              #       Short
Buffer_MouseData_buttons        #       Byte
Buffer_MouseData_time           #       4*Byte
Buffer_MouseData                *       @


;Symbols for SWI's and SWI reason codes
XBuffer_Create                  *       &62940
Buffer_Create                   *       &42940
   ;Entry
   ;  R0 = flags (Buffer_Flags)
   ;  R1 = size (Int)
   ;  R2 = b (Buffer_B)
   ;Exit
   ;  R0 = b_out (Buffer_B)

XBuffer_Remove                  *       &62941
Buffer_Remove                   *       &42941
   ;Entry
   ;  R0 = b (Buffer_B)

XBuffer_Register                *       &62942
Buffer_Register                 *       &42942
   ;Entry
   ;  R0 = flags (Buffer_Flags)
   ;  R1 = buffer (pointer to data)
   ;  R2 = end (pointer to data)
   ;  R3 = b (Buffer_B)
   ;Exit
   ;  R0 = b_out (Buffer_B)

XBuffer_Deregister              *       &62943
Buffer_Deregister               *       &42943
   ;Entry
   ;  R0 = b (Buffer_B)

XBuffer_ModifyFlags             *       &62944
Buffer_ModifyFlags              *       &42944
   ;Entry
   ;  R0 = b (Buffer_B)
   ;  R1 = eor_mask (Bits)
   ;  R2 = and_mask (Bits)

XBuffer_ModifyFlags2            *       &62944
Buffer_ModifyFlags2             *       &42944
   ;Entry
   ;  R0 = b (Buffer_B)
   ;  R1 = eor_mask (Bits)
   ;  R2 = and_mask (Bits)
   ;Exit
   ;  R1 = old_value (Bits)
   ;  R2 = new_value (Bits)

XBuffer_LinkDevice              *       &62945
Buffer_LinkDevice               *       &42945
   ;Entry
   ;  R0 = b (Buffer_B)
   ;  R1 -> wakeup_code (code)
   ;  R2 -> owner_change_code (code)
   ;  R3 = handle (Int)
   ;  R4 = workspace (pointer to Void)

XBuffer_UnlinkDevice            *       &62946
Buffer_UnlinkDevice             *       &42946
   ;Entry
   ;  R0 = b (Buffer_B)

XBuffer_GetInfo                 *       &62947
Buffer_GetInfo                  *       &42947
   ;Entry
   ;  R0 = b (Buffer_B)
   ;Exit
   ;  R0 = flags (Buffer_Flags)
   ;  R1 = buffer (pointer to data)
   ;  R2 = end (pointer to data)
   ;  R3 = insertion_point (Int)
   ;  R4 = removal_point (Int)
   ;  R5 = spare (Int)
   ;  R6 = used (Int)

XBuffer_Threshold               *       &62948
Buffer_Threshold                *       &42948
   ;Entry
   ;  R0 = b (Buffer_B)
   ;  R1 = threshold (Int)
   ;Exit
   ;  R1 = old_threshold (Int)

XBuffer_InternalInfo            *       &62949
Buffer_InternalInfo             *       &42949
   ;Entry
   ;  R0 = b (Buffer_B)
   ;Exit
   ;  R0 = id (Buffer_InternalId)
   ;  R1 -> service_routine (code)
   ;  R2 = workspace (pointer to Void)

InsV                            *       &14
   ;Entry
   ;  R0 = b (Byte)
   ;  R1 = buffer_no (Buffer_No)
   ;  R9 = &14
   ;Exit
   ;  R2 corrupted

InsV_Block                      *       &14
   ;Entry
   ;  R1 = &80000000 :OR: buffer_no (Buffer_No)
   ;  R2 -> data (data)
   ;  R3 = size (Int)
   ;  R9 = &14
   ;Exit
   ;  R2 = end (pointer to Byte)
   ;  R3 corrupted

RemV                            *       &15
   ;Entry
   ;  R1 = buffer_no (Buffer_No)
   ;  R9 = &15
   ;Exit
   ;  R0 = examined_b (Byte)
   ;  R2 = removed_b (Byte)

RemV_Block                      *       &15
   ;Entry
   ;  R1 = &80000000 :OR: buffer_no (Buffer_No)
   ;  R2 = buffer (pointer to data)
   ;  R3 = byte_count (Int)
   ;  R9 = &15
   ;Exit
   ;  R2 -> end (Byte)
   ;  R3 = spare (Int)

CnpV                            *       &16
   ;Entry
   ;  R1 = buffer_no (Buffer_No)
   ;  R9 = &16
   ;Exit
   ;  R0 corrupted
   ;  R1 = lo8bits (Bits)
   ;  R2 = hi24bits (Bits)

Service_BufferStarting          *       &6F
   ;Entry
   ;  R1 = &6F

Event_OutputBufferEmpty         *       &0
   ;Entry
   ;  R0 = &0
   ;  R1 = buffer (Buffer_No)

Event_InputBufferFull           *       &1
   ;Entry
   ;  R0 = &1
   ;  R1 = buffer (Buffer_No)
   ;  R2 = b (Byte)

Event_InputBufferFullBlockOp    *       &1
   ;Entry
   ;  R0 = &1
   ;  R1 = &80000000 :OR: buffer (Buffer_No)
   ;  R2 = data (pointer to data)
   ;  R3 = count (Int)

UpCall_BufferFilling            *       &8
   ;Entry
   ;  R0 = &8
   ;  R1 = b (Buffer_B)
   ;  R2 = &0

UpCall_BufferEmptying           *       &9
   ;Entry
   ;  R0 = &9
   ;  R1 = b (Buffer_B)
   ;  R2 = &FFFFFFFF

        ]
        END
